package model.agent.question

import java.util.ArrayList;
import java.util.Collections;

class YesNoQuestion extends AbstractQuestion implements QuestionInterface{

	String option

	float value

	def valueSep = QuestionSet.valueSep

	@Override
	public float answer(String ans) {

		if(ans.trim().replace(" ","") == option){
			lastResult = value
			return value
		}

		return 0;
	}

	@Override
	public float answer(AbstractList ans) {
		if(ans.contains(option)){
			lastResult = value 
			return value
		}
		return 0;
	}

	@Override
	public ArrayList<String> getOptions() {
		
		return [option]
	}

	def YesNoQuestion(String qString){
		questionString = qString.trim().replace(" ","")
		def parts = questionString.split(valueSep)
		option = parts[0]
		value = parts[1].toFloat()
	}

}
